package com.villaday.idf.adapter;

import android.content.Context;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

import com.villaday.idf.R;
import com.villaday.idf.adapter3.HouseMoneyItemAdapter;
import com.villaday.idf.custom.bannerUtil.AbsRecyclerViewAdapter;
import com.villaday.idf.model3.HashPricesEntity;

import java.util.List;

public class HouseMoneyManageAdapter extends AbsRecyclerViewAdapter<HashPricesEntity.BodyBean.DatesBeanX> {

    View.OnClickListener onClickListener;

    public HouseMoneyManageAdapter(Context context, View.OnClickListener onClickListener) {
        super(context, R.layout.recycle_house_money_manage);
        this.onClickListener = onClickListener;
    }


    @Override
    public void onBindHolder(RecyclerViewHolder holder, HashPricesEntity.BodyBean.DatesBeanX d, int position) {

        List<HashPricesEntity.BodyBean.DatesBeanX.DatesBean> dates = d.getDates();
        RecyclerView rvHmm = (RecyclerView) holder.getView(R.id.rv_hmm);
        rvHmm.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false));
        HouseMoneyItemAdapter houseMoneyItemAdapter = new HouseMoneyItemAdapter(context);
        rvHmm.setAdapter(houseMoneyItemAdapter);
        houseMoneyItemAdapter.setData(dates);
        holder.bindTextView(R.id.tv_hmm_money, d.getCostPrice());


        if ((position + 1) % 2 != 1) {
            holder.getView(R.id.ll_hmm).setBackgroundResource(R.color.colorBackground);
        } else {
            holder.getView(R.id.ll_hmm).setBackgroundResource(R.color.colorWhite);
        }
        holder.getView(R.id.iv_hmm_retire).setTag(position);
        holder.getView(R.id.iv_hmm_retire).setOnClickListener(onClickListener);
        holder.getView(R.id.iv_hmm_delete).setTag(position);
        holder.getView(R.id.iv_hmm_delete).setOnClickListener(onClickListener);
    }
}
